﻿# -*- coding: utf-8 -*-
"""
@author: children1987
"""

from setup_utils import get_config_info, replace_in_file


def main():
    config_info = get_config_info()
    # 使前端项目在dev模式下可被外部访问
    f = '/opt/cmdb-web/config/index.js'
    regex = r'(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)'
    replace_in_file(f, 'localhost', '0.0.0.0')

    f = '/opt/cmdb-web/src/api/index.js'
    ip = config_info['ip']
    replace_in_file(f, regex, ip)


if __name__ == '__main__':
    main()
